package com.todo.delicacy.application.convert;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.todo.common.common.entity.response.page.PageResult;
import com.todo.common.common.enums.EnableTypeEnum;
import com.todo.common.utils.TodoCommonUtils;
import com.todo.content.api.request.InsertContentDetailRequest;
import com.todo.content.api.request.SavePreCheckRequest;
import com.todo.content.api.request.UpdateContentDetailRequest;
import com.todo.content.api.response.ContentDetailResponse;
import com.todo.content.api.response.ContentInfoResponse;
import com.todo.delicacy.application.entity.bo.*;
import com.todo.delicacy.application.entity.condition.FoodInfoConditionBO;
import com.todo.delicacy.application.entity.condition.FoodRecommendDetailConditionBO;
import com.todo.delicacy.application.entity.condition.RestaurantInfoConditionBO;
import com.todo.delicacy.common.enums.FoodTypeEnum;
import com.todo.delicacy.common.enums.RestaurantTypeEnum;
import com.todo.delicacy.iface.backend.request.*;
import com.todo.delicacy.iface.backend.response.BaseFoodInfoResp;
import com.todo.delicacy.iface.backend.response.QueryRestaurantInfoByConditionResp;
import com.todo.delicacy.iface.backend.response.QueryRestaurantInfoByConditionRsp;
import com.todo.delicacy.iface.backend.response.RestaurantDetailInfoResp;
import com.todo.delicacy.iface.frontend.request.QueryRestaurantByPageParam;
import com.todo.delicacy.iface.frontend.response.FoodBaseVO;
import com.todo.delicacy.iface.frontend.response.FoodDetailVO;
import com.todo.delicacy.iface.frontend.response.RestaurantBaseVO;
import com.todo.delicacy.iface.frontend.response.RestaurantDetailVO;
import com.todo.delicacy.infrastructure.entity.condition.ContentFoodRecommendCondition;
import com.todo.delicacy.infrastructure.entity.condition.FoodInfoCondition;
import com.todo.delicacy.infrastructure.entity.condition.RestaurantInfoCondition;
import com.todo.delicacy.infrastructure.entity.po.ContentFoodRecommendPO;
import com.todo.delicacy.infrastructure.entity.po.FoodInfoPO;
import com.todo.delicacy.infrastructure.entity.po.RestaurantInfoPO;
import com.todo.delicacy.service.api.response.RestaurantDetailResponse;
import com.todo.delicacy.service.api.response.RestaurantInfoResponse;
import com.todo.sight.service.api.response.SightPoiDetailResponse;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author azhebuxing
 * @date 2024/6/11 11:09
 * @description
 */
public class FoodConvert {


    public static RestaurantDetailBO convertToRestaurantDetailBO(RestaurantInfoBO restaurantInfoBO, SightPoiDetailResponse sightPoiBO) {
        if (restaurantInfoBO == null) {
            return null;
        }
        RestaurantDetailBO restaurantDetailBO = new RestaurantDetailBO();
        restaurantDetailBO.setRestaurantInfoBO(restaurantInfoBO);
        if (sightPoiBO == null) {
            return restaurantDetailBO;
        }
        RestaurantDetailBO.POIInfo poiInfo = new RestaurantDetailBO.POIInfo();
        poiInfo.setCity(sightPoiBO.getCity());
        poiInfo.setDistrict(sightPoiBO.getDistrict());
        poiInfo.setTown(sightPoiBO.getTown());
        poiInfo.setProvince(sightPoiBO.getProvince());
        poiInfo.setPoiType(sightPoiBO.getPoiType());
        poiInfo.setTypeList(sightPoiBO.getTypeList());
        poiInfo.setAddress(sightPoiBO.getAddress());
        poiInfo.setLon(sightPoiBO.getLon());
        poiInfo.setLat(sightPoiBO.getLat());
        poiInfo.setIsShow(sightPoiBO.getIsShow() == null ? EnableTypeEnum.FORBIDDEN.getType() : sightPoiBO.getIsShow().getType());

        restaurantDetailBO.setPoiInfo(poiInfo);
        return restaurantDetailBO;
    }

    public static RestaurantInfoCondition convertToRestaurantInfoCondition(RestaurantInfoConditionBO conditionBO) {
        if (conditionBO == null) {
            return null;
        }
        RestaurantInfoCondition condition = new RestaurantInfoCondition();
        condition.setCity(conditionBO.getCity());
        condition.setCurrentIndex(conditionBO.getCurrentIndex());
        condition.setIsOpen(conditionBO.getIsOpen() == null ? null : conditionBO.getIsOpen().getType());
        condition.setMaxCost(conditionBO.getMaxCost());
        condition.setMinCost(conditionBO.getMinCost());
        condition.setPageIndex(conditionBO.getPageIndex());
        condition.setPageSize(conditionBO.getPageSize());
        condition.setProvince(conditionBO.getProvince());
        condition.setRestaurantType(conditionBO.getRestaurantType() == null ? null : conditionBO.getRestaurantType().getType());
        condition.setStorePoiId(conditionBO.getStorePoiId());
        return condition;
    }

    public static RestaurantInfoPO convertToRestaurantInfoPO(RestaurantInfoBO restaurantInfoBO) {
        if (restaurantInfoBO == null) {
            return null;
        }
        RestaurantInfoPO restaurantInfoPO = new RestaurantInfoPO();
        restaurantInfoPO.setId(restaurantInfoBO.getRestaurantId() == null ? TodoCommonUtils.buildLongGuid() : restaurantInfoBO.getRestaurantId());
        restaurantInfoPO.setStorePoiId(restaurantInfoBO.getStorePoiId());
        restaurantInfoPO.setExtra(JSONObject.toJSONString(restaurantInfoBO.getExtra()));
        restaurantInfoPO.setCity(restaurantInfoBO.getCity());
        restaurantInfoPO.setProvince(restaurantInfoBO.getProvince());
        restaurantInfoPO.setName(restaurantInfoBO.getName());
        restaurantInfoPO.setMainImg(restaurantInfoBO.getMainImg());
        restaurantInfoPO.setDesc(restaurantInfoBO.getDesc());
        restaurantInfoPO.setIsOpen(restaurantInfoBO.getIsOpen().getType());
        restaurantInfoPO.setMoneyCost(restaurantInfoBO.getMoneyCost());
        restaurantInfoPO.setBusinessTime(restaurantInfoBO.getBusinessTime());
        restaurantInfoPO.setRestaurantType(restaurantInfoBO.getRestaurantType().getType());
        restaurantInfoPO.setContactInfo(restaurantInfoBO.getContactInfo());
        restaurantInfoPO.setScore(restaurantInfoBO.getScore());
        restaurantInfoPO.setIsDelete(0);
        restaurantInfoPO.setCreateTime(new Date());
        restaurantInfoPO.setUpdateTime(new Date());
        return restaurantInfoPO;
    }


    public static UpdateContentDetailRequest buildToUpdateContentDetailRequest(FoodRecommendDetailBO foodRecommendDetailBO) {
        if (foodRecommendDetailBO == null || foodRecommendDetailBO.getFoodContentBO() == null) {
            return null;
        }
        FoodContentBO foodContentBO = foodRecommendDetailBO.getFoodContentBO();
        UpdateContentDetailRequest request = new UpdateContentDetailRequest();
        request.setContent(foodContentBO.getContent());
        request.setContentId(foodContentBO.getContentId());
        request.setMainImg(foodContentBO.getMainImg());
        request.setTitle(foodContentBO.getTitle());
        request.setUserId(foodContentBO.getUserId());
        request.setAllowComment(foodContentBO.getAllowComment());
        request.setIsPrivate(foodContentBO.getIsPrivate());
        return request;
    }

    public static SavePreCheckRequest buildToSavePreCheckRequest(FoodRecommendDetailBO foodRecommendDetailBO, Boolean isInsert) {
        if (foodRecommendDetailBO == null || foodRecommendDetailBO.getFoodContentBO() == null) {
            return null;
        }
        FoodContentBO foodContentBO = foodRecommendDetailBO.getFoodContentBO();
        SavePreCheckRequest request = new SavePreCheckRequest();
        request.setContent(foodContentBO.getContent());
        request.setClassifyCode("food_content");
        request.setMainImg(foodContentBO.getMainImg());
        request.setTitle(foodContentBO.getTitle());
        request.setUserId(foodContentBO.getUserId());
        request.setAllowComment(foodContentBO.getAllowComment());
        request.setIsPrivate(foodContentBO.getIsPrivate());
        request.setIsInsert(isInsert);
        return request;
    }

    public static FoodInfoPO convertToFoodInfoPO(FoodInfoBO foodInfoBO) {
        if (foodInfoBO == null) {
            return null;
        }
        FoodInfoPO foodInfoPO = new FoodInfoPO();
        foodInfoPO.setId(foodInfoBO.getFoodId() == null ? TodoCommonUtils.buildLongGuid() : foodInfoBO.getFoodId());
        foodInfoPO.setBatching(JSONObject.toJSONString(foodInfoBO.getBatching()));
        foodInfoPO.setDesc(foodInfoBO.getDesc());
        foodInfoPO.setExtra(JSONObject.toJSONString(foodInfoBO.getExtra()));
        foodInfoPO.setFoodType(foodInfoBO.getFoodType().getType());
        foodInfoPO.setIsDelete(0);
        foodInfoPO.setMainImg(foodInfoBO.getMainImg());
        foodInfoPO.setName(foodInfoBO.getName());
        foodInfoPO.setPrice(foodInfoBO.getPrice());
        foodInfoPO.setRestaurantId(foodInfoBO.getRestaurantId());
        foodInfoPO.setRecommend(foodInfoBO.getRecommend());
        foodInfoPO.setSort(foodInfoBO.getSort());
        foodInfoPO.setIsDelete(0);
        foodInfoPO.setCreateTime(new Date());
        foodInfoPO.setUpdateTime(new Date());
        return foodInfoPO;
    }

    public static ContentFoodRecommendPO convertToContentFoodRecommendPO(FoodRecommendDetailBO foodRecommendDetailBO) {
        ContentFoodRecommendPO contentFoodRecommendPO = new ContentFoodRecommendPO();
        if (foodRecommendDetailBO != null && foodRecommendDetailBO.getFoodRecommendBO() != null) {
            FoodRecommendBO foodRecommendBO = foodRecommendDetailBO.getFoodRecommendBO();
            contentFoodRecommendPO.setFoodType(foodRecommendBO.getFoodType().getType());
            contentFoodRecommendPO.setRecommend(foodRecommendBO.getRecommend());
            contentFoodRecommendPO.setRelationName(foodRecommendBO.getRelationName());
            contentFoodRecommendPO.setRelationPoi(foodRecommendBO.getRelationPoi());
            contentFoodRecommendPO.setExtra(JSONObject.toJSONString(foodRecommendBO.getExtra()));
            contentFoodRecommendPO.setNegative(foodRecommendBO.getNegative());
            contentFoodRecommendPO.setEndorse(foodRecommendBO.getEndorse());
            contentFoodRecommendPO.setCity(foodRecommendBO.getCity());
            contentFoodRecommendPO.setProvince(foodRecommendBO.getProvince());
            contentFoodRecommendPO.setAddress(foodRecommendBO.getAddress());
            contentFoodRecommendPO.setUserId(foodRecommendBO.getUserId());
            contentFoodRecommendPO.setContentId(foodRecommendBO.getContentId());
            contentFoodRecommendPO.setId(foodRecommendBO.getId());
            return contentFoodRecommendPO;
        }
        return null;
    }

    public static FoodRecommendDetailBO buildFoodRecommendDetailBO(ContentDetailResponse contentDetailResponse, ContentFoodRecommendPO contentFoodRecommendPO) {
        if (contentDetailResponse == null || contentFoodRecommendPO == null) {
            return null;
        }
        FoodRecommendDetailBO foodRecommendDetailBO = new FoodRecommendDetailBO();
        FoodRecommendBO foodRecommendBO = new FoodRecommendBO();

        foodRecommendBO.setFoodType(FoodTypeEnum.getByType(contentFoodRecommendPO.getFoodType()));
        foodRecommendBO.setRecommend(contentFoodRecommendPO.getRecommend());
        foodRecommendBO.setRelationName(contentFoodRecommendPO.getRelationName());
        foodRecommendBO.setRelationPoi(contentFoodRecommendPO.getRelationPoi());
        foodRecommendBO.setExtra(JSONObject.parseObject(contentFoodRecommendPO.getExtra(), FoodRecommendBO.Extra.class));
        foodRecommendBO.setNegative(contentFoodRecommendPO.getNegative());
        foodRecommendBO.setEndorse(contentFoodRecommendPO.getEndorse());
        foodRecommendBO.setCity(contentFoodRecommendPO.getCity());
        foodRecommendBO.setProvince(contentFoodRecommendPO.getProvince());
        foodRecommendBO.setAddress(contentFoodRecommendPO.getAddress());
        foodRecommendBO.setUserId(contentFoodRecommendPO.getUserId());
        foodRecommendBO.setContentId(contentFoodRecommendPO.getContentId());
        foodRecommendBO.setId(contentFoodRecommendPO.getId());
        foodRecommendDetailBO.setFoodRecommendBO(foodRecommendBO);

        FoodContentBO foodContentBO = new FoodContentBO();
        foodContentBO.setContent(contentDetailResponse.getContent());
        foodContentBO.setContentId(contentDetailResponse.getContentId());
        foodContentBO.setMainImg(contentDetailResponse.getMainImg());
        foodContentBO.setStatus(contentDetailResponse.getStatus());
        foodContentBO.setTitle(contentDetailResponse.getTitle());
        foodContentBO.setUserId(contentDetailResponse.getUserId());
        foodContentBO.setAllowComment(contentDetailResponse.getAllowComment());
        foodContentBO.setSeeCount(contentDetailResponse.getSeeCount());
        foodContentBO.setCommentCount(contentDetailResponse.getCommentCount());
        foodContentBO.setIsPrivate(contentDetailResponse.getIsPrivate());
        foodContentBO.setLikeCount(contentDetailResponse.getLikeCount());
        foodRecommendDetailBO.setFoodContentBO(foodContentBO);
        return foodRecommendDetailBO;
    }

    public static FoodRecommendDetailBO buildFoodRecommendDetailBO(ContentInfoResponse contentInfoResponse, ContentFoodRecommendPO contentFoodRecommendPO) {
        if (contentFoodRecommendPO == null || contentInfoResponse == null) {
            return null;
        }

        FoodRecommendDetailBO foodRecommendDetailBO = new FoodRecommendDetailBO();
        FoodRecommendBO foodRecommendBO = new FoodRecommendBO();

        foodRecommendBO.setFoodType(FoodTypeEnum.getByType(contentFoodRecommendPO.getFoodType()));
        foodRecommendBO.setRecommend(contentFoodRecommendPO.getRecommend());
        foodRecommendBO.setRelationName(contentFoodRecommendPO.getRelationName());
        foodRecommendBO.setRelationPoi(contentFoodRecommendPO.getRelationPoi());
        foodRecommendBO.setExtra(JSONObject.parseObject(contentFoodRecommendPO.getExtra(), FoodRecommendBO.Extra.class));
        foodRecommendBO.setNegative(contentFoodRecommendPO.getNegative());
        foodRecommendBO.setEndorse(contentFoodRecommendPO.getEndorse());
        foodRecommendBO.setCity(contentFoodRecommendPO.getCity());
        foodRecommendBO.setProvince(contentFoodRecommendPO.getProvince());
        foodRecommendBO.setAddress(contentFoodRecommendPO.getAddress());
        foodRecommendBO.setUserId(contentFoodRecommendPO.getUserId());
        foodRecommendBO.setContentId(contentFoodRecommendPO.getContentId());
        foodRecommendBO.setId(contentFoodRecommendPO.getId());
        foodRecommendDetailBO.setFoodRecommendBO(foodRecommendBO);

        FoodContentBO foodContentBO = new FoodContentBO();
        foodContentBO.setContent(contentInfoResponse.getContent());
        foodContentBO.setContentId(contentInfoResponse.getContentId());
        foodContentBO.setMainImg(contentInfoResponse.getMainImg());
        foodContentBO.setStatus(contentInfoResponse.getStatus());
        foodContentBO.setTitle(contentInfoResponse.getTitle());
        foodContentBO.setUserId(contentInfoResponse.getUserId());
        foodContentBO.setAllowComment(contentInfoResponse.getAllowComment());
        foodContentBO.setSeeCount(contentInfoResponse.getSeeCount());
        foodContentBO.setCommentCount(contentInfoResponse.getCommentCount());
        foodContentBO.setIsPrivate(contentInfoResponse.getIsPrivate());
        foodContentBO.setLikeCount(contentInfoResponse.getLikeCount());
        foodRecommendDetailBO.setFoodContentBO(foodContentBO);
        return foodRecommendDetailBO;
    }

    public static ContentFoodRecommendCondition convertToContentFoodRecommendCondition(FoodRecommendDetailConditionBO conditionBO) {
        if (conditionBO == null) {
            return null;
        }
        ContentFoodRecommendCondition condition = new ContentFoodRecommendCondition();
        condition.setCurrentIndex(conditionBO.getCurrentIndex());
        condition.setPageIndex(conditionBO.getPageIndex());
        condition.setPageSize(conditionBO.getPageSize());
        condition.setFoodType(conditionBO.getFoodType() == null ? null : conditionBO.getFoodType().getType());
        condition.setUserId(conditionBO.getUserId());
        condition.setRelationPoi(conditionBO.getRelationPoi());
        condition.setRelationName(conditionBO.getRelationName());
        condition.setProvince(conditionBO.getProvince());
        condition.setCity(conditionBO.getCity());
        return condition;
    }

    public static List<RestaurantInfoBO> convertToRestaurantInfoBOList(List<RestaurantInfoPO> restaurantInfoPOList) {
        if (CollectionUtils.isEmpty(restaurantInfoPOList)) {
            return Lists.newArrayList();
        }
        return restaurantInfoPOList.stream().map(FoodConvert::convertToRestaurantInfoBO).collect(Collectors.toList());
    }

    public static RestaurantInfoBO convertToRestaurantInfoBO(RestaurantInfoPO restaurantInfoPO) {
        if (restaurantInfoPO == null) {
            return null;
        }
        RestaurantInfoBO restaurantInfoBO = new RestaurantInfoBO();
        restaurantInfoBO.setStorePoiId(restaurantInfoPO.getStorePoiId());
        restaurantInfoBO.setExtra(JSONObject.parseObject(restaurantInfoPO.getExtra(), RestaurantInfoBO.Extra.class));
        restaurantInfoBO.setCity(restaurantInfoPO.getCity());
        restaurantInfoBO.setProvince(restaurantInfoPO.getProvince());
        restaurantInfoBO.setName(restaurantInfoPO.getName());
        restaurantInfoBO.setMainImg(restaurantInfoPO.getMainImg());
        restaurantInfoBO.setDesc(restaurantInfoPO.getDesc());
        restaurantInfoBO.setIsOpen(EnableTypeEnum.getByType(restaurantInfoPO.getIsOpen()));
        restaurantInfoBO.setMoneyCost(restaurantInfoPO.getMoneyCost());
        restaurantInfoBO.setBusinessTime(restaurantInfoPO.getBusinessTime());
        restaurantInfoBO.setRestaurantType(RestaurantTypeEnum.getByType(restaurantInfoPO.getRestaurantType()));
        restaurantInfoBO.setContactInfo(restaurantInfoPO.getContactInfo());
        restaurantInfoBO.setScore(restaurantInfoPO.getScore());
        restaurantInfoBO.setRestaurantId(restaurantInfoPO.getId());
        return restaurantInfoBO;
    }

    public static RestaurantInfoBO convertToRestaurantInfoBO(InsertRestaurantInfoReq req) {
        if (req == null) {
            return null;
        }
        RestaurantInfoBO restaurantInfoBO = new RestaurantInfoBO();
        restaurantInfoBO.setRestaurantType(RestaurantTypeEnum.getByType(req.getRestaurantType()));
        restaurantInfoBO.setName(req.getName());
        restaurantInfoBO.setCity(req.getCity());
        restaurantInfoBO.setProvince(req.getProvince());
        restaurantInfoBO.setScore(req.getScore());
        restaurantInfoBO.setContactInfo(req.getContactInfo());
        restaurantInfoBO.setMainImg(req.getMainImg());
        restaurantInfoBO.setBusinessTime(req.getBusinessTime());
        restaurantInfoBO.setMoneyCost(req.getMoneyCost());
        restaurantInfoBO.setDesc(req.getDesc());
        restaurantInfoBO.setStorePoiId(req.getStorePoiId());
        restaurantInfoBO.setIsOpen(EnableTypeEnum.getByType(req.getIsOpen()));
        return restaurantInfoBO;
    }

    public static RestaurantInfoBO convertToRestaurantInfoBO(UpdateRestaurantInfoReq req) {
        if (req == null) {
            return null;
        }
        RestaurantInfoBO restaurantInfoBO = new RestaurantInfoBO();
        restaurantInfoBO.setRestaurantId(req.getRestaurantId());
        restaurantInfoBO.setRestaurantType(RestaurantTypeEnum.getByType(req.getRestaurantType()));
        restaurantInfoBO.setName(req.getName());
        restaurantInfoBO.setCity(req.getCity());
        restaurantInfoBO.setProvince(req.getProvince());
        restaurantInfoBO.setScore(req.getScore());
        restaurantInfoBO.setContactInfo(req.getContactInfo());
        restaurantInfoBO.setMainImg(req.getMainImg());
        restaurantInfoBO.setBusinessTime(req.getBusinessTime());
        restaurantInfoBO.setMoneyCost(req.getMoneyCost());
        restaurantInfoBO.setDesc(req.getDesc());
        restaurantInfoBO.setStorePoiId(req.getStorePoiId());
        restaurantInfoBO.setIsOpen(EnableTypeEnum.getByType(req.getIsOpen()));
        return restaurantInfoBO;
    }


    public static RestaurantDetailInfoResp convertToRestaurantDetailInfoResp(RestaurantDetailBO restaurantDetailBO) {
        if (restaurantDetailBO == null || restaurantDetailBO.getRestaurantInfoBO() == null) {
            return null;
        }
        RestaurantInfoBO restaurantInfoBO = restaurantDetailBO.getRestaurantInfoBO();
        RestaurantDetailInfoResp restaurantDetailInfoResp = new RestaurantDetailInfoResp();
        restaurantDetailInfoResp.setName(restaurantInfoBO.getName());
        restaurantDetailInfoResp.setCity(restaurantInfoBO.getCity());
        restaurantDetailInfoResp.setProvince(restaurantInfoBO.getProvince());
        restaurantDetailInfoResp.setScore(restaurantInfoBO.getScore());
        restaurantDetailInfoResp.setContactInfo(restaurantInfoBO.getContactInfo());
        restaurantDetailInfoResp.setMainImg(restaurantInfoBO.getMainImg());
        restaurantDetailInfoResp.setBusinessTime(restaurantInfoBO.getBusinessTime());
        restaurantDetailInfoResp.setMoneyCost(restaurantInfoBO.getMoneyCost());
        restaurantDetailInfoResp.setDesc(restaurantInfoBO.getDesc());
        restaurantDetailInfoResp.setRestaurantType(restaurantInfoBO.getRestaurantType() == null ? null : restaurantInfoBO.getRestaurantType().getType());
        restaurantDetailInfoResp.setRestaurantTypeStr(restaurantInfoBO.getRestaurantType() == null ? null : restaurantInfoBO.getRestaurantType().getName());
        restaurantDetailInfoResp.setStorePoiId(restaurantInfoBO.getStorePoiId());
        restaurantDetailInfoResp.setIsOpen(restaurantInfoBO.getIsOpen().getType());
        restaurantDetailInfoResp.setRestaurantId(restaurantInfoBO.getRestaurantId());
        restaurantDetailInfoResp.setImgList(restaurantInfoBO.getExtra() == null ? null : restaurantInfoBO.getExtra().getImgList());
        return restaurantDetailInfoResp;
    }

    public static RestaurantInfoConditionBO convertToRestaurantInfoConditionBO(QueryRestaurantInfoByConditionReq req) {
        if (req == null) {
            return null;
        }
        RestaurantInfoConditionBO conditionBO = new RestaurantInfoConditionBO();
        conditionBO.setCurrentIndex(req.getCurrentIndex());
        conditionBO.setPageIndex(req.getPageIndex());
        conditionBO.setPageSize(req.getPageSize());
        conditionBO.setRestaurantType(RestaurantTypeEnum.getByType(req.getRestaurantType()));
        conditionBO.setName(req.getName());
        conditionBO.setProvince(req.getProvince());
        conditionBO.setCity(req.getCity());
        conditionBO.setIsOpen(EnableTypeEnum.getByType(req.getIsOpen()));
        conditionBO.setStorePoiId(req.getStorePoiId());
        return conditionBO;
    }

    public static RestaurantInfoConditionBO convertToRestaurantInfoConditionBO(QueryRestaurantByPageParam param) {
        if (param == null) {
            return null;
        }
        RestaurantInfoConditionBO conditionBO = new RestaurantInfoConditionBO();
        conditionBO.setCurrentIndex(param.getCurrentIndex());
        conditionBO.setPageIndex(param.getPageIndex());
        conditionBO.setPageSize(param.getPageSize());
        conditionBO.setRestaurantType(RestaurantTypeEnum.getByType(param.getRestaurantType()));
        conditionBO.setCity(param.getCity());
        return conditionBO;
    }

    public static PageResult<QueryRestaurantInfoByConditionResp> convertToQueryRestaurantInfoByConditionRespPage(PageResult<RestaurantInfoBO> result) {
        if (result == null) {
            return null;
        }
        if (CollectionUtils.isEmpty(result.getResults())) {
            return PageResult.of(new ArrayList<>(), result.getPageNum(), result.getPageSize(), result.getTotal());
        }
        PageResult<QueryRestaurantInfoByConditionResp> pageResult = new PageResult<>();
        pageResult.setPageCount(result.getPageCount());
        pageResult.setCurrentIndex(result.getCurrentIndex());
        pageResult.setHasNext(result.isHasNext());
        pageResult.setPageNum(result.getPageNum());
        pageResult.setPageSize(result.getPageSize());
        pageResult.setTotal(result.getTotal());
        pageResult.setResults(result.getResults().stream().map(FoodConvert::convertToQueryRestaurantInfoByConditionResp).collect(Collectors.toList()));
        return pageResult;
    }

    public static QueryRestaurantInfoByConditionResp convertToQueryRestaurantInfoByConditionResp(RestaurantInfoBO restaurantInfoBO) {
        if (restaurantInfoBO == null) {
            return null;
        }
        QueryRestaurantInfoByConditionResp queryRestaurantInfoByConditionResp = new QueryRestaurantInfoByConditionResp();
        queryRestaurantInfoByConditionResp.setName(restaurantInfoBO.getName());
        queryRestaurantInfoByConditionResp.setCity(restaurantInfoBO.getCity());
        queryRestaurantInfoByConditionResp.setProvince(restaurantInfoBO.getProvince());
        queryRestaurantInfoByConditionResp.setScore(restaurantInfoBO.getScore());
        queryRestaurantInfoByConditionResp.setRestaurantId(restaurantInfoBO.getRestaurantId());
        queryRestaurantInfoByConditionResp.setMoneyCost(restaurantInfoBO.getMoneyCost());
        queryRestaurantInfoByConditionResp.setRestaurantType(restaurantInfoBO.getRestaurantType() == null ? null : restaurantInfoBO.getRestaurantType().getType());
        queryRestaurantInfoByConditionResp.setStorePoiId(restaurantInfoBO.getStorePoiId());
        queryRestaurantInfoByConditionResp.setIsOpen(restaurantInfoBO.getIsOpen() == null ? null : restaurantInfoBO.getIsOpen().getType());
        return queryRestaurantInfoByConditionResp;
    }

    public static BaseFoodInfoResp convertToBaseFoodInfoResp(FoodInfoBO foodInfoBO) {
        if (foodInfoBO == null) {
            return null;
        }
        BaseFoodInfoResp baseFoodInfoResp = new BaseFoodInfoResp();
        baseFoodInfoResp.setName(foodInfoBO.getName());
        baseFoodInfoResp.setDesc(foodInfoBO.getDesc());
        baseFoodInfoResp.setFoodType(foodInfoBO.getFoodType().getType());
        baseFoodInfoResp.setFoodTypeStr(foodInfoBO.getFoodType().getName());
        baseFoodInfoResp.setFoodId(foodInfoBO.getFoodId());
        if (foodInfoBO.getBatching() != null) {
            FoodInfoBO.FoodBatching originalBatching = foodInfoBO.getBatching();
            BaseFoodInfoResp.FoodBatching foodBatching = new BaseFoodInfoResp.FoodBatching();
            foodBatching.setBatching(originalBatching.getBatching());
            foodBatching.setMakeWay(originalBatching.getMakeWay());
            baseFoodInfoResp.setBatching(foodBatching);
        }
        baseFoodInfoResp.setPrice(foodInfoBO.getPrice());
        baseFoodInfoResp.setSort(foodInfoBO.getSort());
        baseFoodInfoResp.setRecommend(foodInfoBO.getRecommend());
        baseFoodInfoResp.setMainImg(foodInfoBO.getMainImg());
        if (foodInfoBO.getExtra() != null) {
            baseFoodInfoResp.setImgList(foodInfoBO.getExtra().getImgList());
            if (foodInfoBO.getExtra().getOutSideRelationList() != null) {
                List<BaseFoodInfoResp.OutSideRelation> outSideRelationList = new ArrayList<>();
                for (FoodInfoBO.OutSideRelation originalOutSideRelation : foodInfoBO.getExtra().getOutSideRelationList()) {
                    BaseFoodInfoResp.OutSideRelation outSideRelation = new BaseFoodInfoResp.OutSideRelation();
                    outSideRelation.setJumpUrl(originalOutSideRelation.getJumpUrl());
                    outSideRelation.setRelationPlatform(originalOutSideRelation.getRelationPlatform());
                    outSideRelation.setExploreRecommend(originalOutSideRelation.getExploreRecommend());
                    outSideRelationList.add(outSideRelation);
                }
                baseFoodInfoResp.setOutSideRelationList(outSideRelationList);
            }
        }
        baseFoodInfoResp.setRestaurantId(foodInfoBO.getRestaurantId());
        return baseFoodInfoResp;
    }

    public static FoodInfoBO convertToFoodInfoBO(FoodInfoPO foodInfoPO) {
        FoodInfoBO foodInfoBO = new FoodInfoBO();
        foodInfoBO.setBatching(JSONObject.parseObject(foodInfoPO.getBatching(), FoodInfoBO.FoodBatching.class));
        foodInfoBO.setExtra(JSONObject.parseObject(foodInfoPO.getExtra(), FoodInfoBO.Extra.class));
        foodInfoBO.setFoodId(foodInfoPO.getId());
        foodInfoBO.setFoodType(FoodTypeEnum.getByType(foodInfoPO.getFoodType()));
        foodInfoBO.setMainImg(foodInfoPO.getMainImg());
        foodInfoBO.setDesc(foodInfoPO.getDesc());
        foodInfoBO.setName(foodInfoPO.getName());
        foodInfoBO.setPrice(foodInfoPO.getPrice());
        foodInfoBO.setRestaurantId(foodInfoPO.getRestaurantId());
        foodInfoBO.setRecommend(foodInfoPO.getRecommend());
        foodInfoBO.setSort(foodInfoPO.getSort());
        return foodInfoBO;
    }

    public static FoodInfoCondition convertToFoodInfoCondition(FoodInfoConditionBO conditionBO) {
        FoodInfoCondition foodInfoCondition = new FoodInfoCondition();
        foodInfoCondition.setFoodType(conditionBO.getFoodType() == null ? null : conditionBO.getFoodType().getType());
        foodInfoCondition.setName(conditionBO.getName());
        foodInfoCondition.setRestaurantId(conditionBO.getRestaurantId());
        foodInfoCondition.setPageIndex(conditionBO.getPageIndex());
        foodInfoCondition.setPageSize(conditionBO.getPageSize());
        foodInfoCondition.setCurrentIndex(conditionBO.getCurrentIndex());
        return foodInfoCondition;
    }

    public static FoodInfoBO convertToFoodInfoBO(InsertFoodInfoReq req) {
        if (req == null) {
            return null;
        }
        FoodInfoBO foodInfoBO = new FoodInfoBO();
        foodInfoBO.setName(req.getName());
        foodInfoBO.setDesc(req.getDesc());
        foodInfoBO.setFoodType(FoodTypeEnum.getByType(req.getFoodType()));
        foodInfoBO.setPrice(req.getPrice());
        if (req.getBatching() != null) {
            FoodInfoBO.FoodBatching foodBatching = new FoodInfoBO.FoodBatching();
            foodBatching.setBatching(req.getBatching().getBatching());
            foodBatching.setMakeWay(req.getBatching().getMakeWay());
            foodInfoBO.setBatching(foodBatching);
        }
        foodInfoBO.setRecommend(req.getRecommend());
        foodInfoBO.setSort(req.getSort());
        FoodInfoBO.Extra extra = new FoodInfoBO.Extra();
        extra.setImgList(req.getImgList());
        if (req.getOutSideRelationList() != null) {
            List<FoodInfoBO.OutSideRelation> outSideRelationList = new ArrayList<>();
            for (InsertFoodInfoReq.OutSideRelation originalOutSideRelation : req.getOutSideRelationList()) {
                FoodInfoBO.OutSideRelation outSideRelation = new FoodInfoBO.OutSideRelation();
                outSideRelation.setJumpUrl(originalOutSideRelation.getJumpUrl());
                outSideRelation.setRelationPlatform(originalOutSideRelation.getRelationPlatform());
                outSideRelation.setExploreRecommend(originalOutSideRelation.getExploreRecommend());
                outSideRelationList.add(outSideRelation);
            }
            extra.setOutSideRelationList(outSideRelationList);
        }
        foodInfoBO.setExtra(extra);
        foodInfoBO.setMainImg(req.getMainImg());
        foodInfoBO.setRestaurantId(req.getRestaurantId());
        return foodInfoBO;
    }

    public static FoodInfoBO convertToFoodInfoBO(UpdateFoodInfoReq req) {
        if (req == null) {
            return null;
        }
        FoodInfoBO foodInfoBO = new FoodInfoBO();
        foodInfoBO.setFoodId(req.getFoodId());
        foodInfoBO.setName(req.getName());
        foodInfoBO.setDesc(req.getDesc());
        foodInfoBO.setFoodType(FoodTypeEnum.getByType(req.getFoodType()));
        foodInfoBO.setPrice(req.getPrice());
        if (req.getBatching() != null) {
            FoodInfoBO.FoodBatching foodBatching = new FoodInfoBO.FoodBatching();
            foodBatching.setBatching(req.getBatching().getBatching());
            foodBatching.setMakeWay(req.getBatching().getMakeWay());
            foodInfoBO.setBatching(foodBatching);
        }
        foodInfoBO.setRecommend(req.getRecommend());
        foodInfoBO.setSort(req.getSort());
        FoodInfoBO.Extra extra = new FoodInfoBO.Extra();
        extra.setImgList(req.getImgList());
        if (req.getOutSideRelationList() != null) {
            List<FoodInfoBO.OutSideRelation> outSideRelationList = new ArrayList<>();
            for (UpdateFoodInfoReq.OutSideRelation originalOutSideRelation : req.getOutSideRelationList()) {
                FoodInfoBO.OutSideRelation outSideRelation = new FoodInfoBO.OutSideRelation();
                outSideRelation.setJumpUrl(originalOutSideRelation.getJumpUrl());
                outSideRelation.setRelationPlatform(originalOutSideRelation.getRelationPlatform());
                outSideRelation.setExploreRecommend(originalOutSideRelation.getExploreRecommend());
                outSideRelationList.add(outSideRelation);
            }
            extra.setOutSideRelationList(outSideRelationList);
        }
        foodInfoBO.setExtra(extra);
        foodInfoBO.setRestaurantId(req.getRestaurantId());
        return foodInfoBO;
    }


    public static FoodInfoConditionBO convertToFoodInfoConditionBO(QueryFoodInfoByConditionReq req) {
        if (req == null) {
            return null;
        }
        FoodInfoConditionBO foodInfoConditionBO = new FoodInfoConditionBO();
        foodInfoConditionBO.setPageIndex(req.getPageIndex());
        foodInfoConditionBO.setPageSize(req.getPageSize());
        foodInfoConditionBO.setCurrentIndex(req.getCurrentIndex());
        foodInfoConditionBO.setFoodType(FoodTypeEnum.getByType(req.getFoodType()));
        foodInfoConditionBO.setName(req.getName());
        foodInfoConditionBO.setRestaurantId(req.getRestaurantId());
        return foodInfoConditionBO;
    }

    public static PageResult<QueryRestaurantInfoByConditionRsp> convertToQueryRestaurantInfoByConditionRspPage(PageResult<FoodInfoBO> result) {
        if (result == null) {
            return null;
        }
        if (CollectionUtils.isEmpty(result.getResults())) {
            return PageResult.of(new ArrayList<>(), result.getPageNum(), result.getPageSize(), result.getTotal());
        }
        PageResult<QueryRestaurantInfoByConditionRsp> pageResult = new PageResult<>();
        pageResult.setPageCount(result.getPageCount());
        pageResult.setCurrentIndex(result.getCurrentIndex());
        pageResult.setHasNext(result.isHasNext());
        pageResult.setPageNum(result.getPageNum());
        pageResult.setPageSize(result.getPageSize());
        pageResult.setTotal(result.getTotal());
        pageResult.setResults(result.getResults().stream().map(FoodConvert::convertToQueryRestaurantInfoByConditionRsp).collect(Collectors.toList()));
        return pageResult;
    }

    private static QueryRestaurantInfoByConditionRsp convertToQueryRestaurantInfoByConditionRsp(FoodInfoBO foodInfoBO) {
        if (foodInfoBO == null) {
            return null;
        }
        QueryRestaurantInfoByConditionRsp queryRestaurantInfoByConditionRsp = new QueryRestaurantInfoByConditionRsp();
        queryRestaurantInfoByConditionRsp.setId(foodInfoBO.getRestaurantId());
        queryRestaurantInfoByConditionRsp.setName(foodInfoBO.getName());
        queryRestaurantInfoByConditionRsp.setFoodType(foodInfoBO.getFoodType() == null ? null : foodInfoBO.getFoodType().getType());
        queryRestaurantInfoByConditionRsp.setPrice(foodInfoBO.getPrice());
        queryRestaurantInfoByConditionRsp.setMainImg(foodInfoBO.getMainImg());
        queryRestaurantInfoByConditionRsp.setSort(foodInfoBO.getSort());
        queryRestaurantInfoByConditionRsp.setRestaurantId(foodInfoBO.getRestaurantId());
        return queryRestaurantInfoByConditionRsp;
    }

    public static InsertContentDetailRequest buildToInsertContentDetailRequest(FoodRecommendDetailBO foodRecommendDetailBO) {
        if (foodRecommendDetailBO == null || foodRecommendDetailBO.getFoodContentBO() == null) {
            return null;
        }
        InsertContentDetailRequest request = new InsertContentDetailRequest();
        FoodContentBO foodContentBO = foodRecommendDetailBO.getFoodContentBO();
        request.setContent(foodContentBO.getContent());
        request.setMainImg(foodContentBO.getMainImg());
        request.setTitle(foodContentBO.getTitle());
        request.setUserId(foodContentBO.getUserId());
        request.setAllowComment(foodContentBO.getAllowComment());
        request.setIsPrivate(foodContentBO.getIsPrivate());
        return request;
    }

    public static RestaurantDetailResponse convertToRestaurantDetailResponse(RestaurantDetailBO restaurantDetailBO) {
        if (restaurantDetailBO == null || restaurantDetailBO.getRestaurantInfoBO() == null) {
            return null;
        }
        RestaurantDetailResponse restaurantDetailResponse = new RestaurantDetailResponse();
        RestaurantInfoBO restaurantInfoBO = restaurantDetailBO.getRestaurantInfoBO();
        restaurantDetailResponse.setRestaurantId(restaurantInfoBO.getRestaurantId());
        restaurantDetailResponse.setStorePoiId(restaurantInfoBO.getStorePoiId());
        restaurantDetailResponse.setName(restaurantInfoBO.getName());
        restaurantDetailResponse.setDesc(restaurantInfoBO.getDesc());
        restaurantDetailResponse.setRestaurantType(restaurantInfoBO.getRestaurantType());
        restaurantDetailResponse.setMoneyCost(restaurantInfoBO.getMoneyCost());
        restaurantDetailResponse.setScore(restaurantInfoBO.getScore());
        restaurantDetailResponse.setMainImg(restaurantInfoBO.getMainImg());
        restaurantDetailResponse.setBusinessTime(restaurantInfoBO.getBusinessTime());
        restaurantDetailResponse.setContactInfo(restaurantInfoBO.getContactInfo());
        restaurantDetailResponse.setIsOpen(restaurantInfoBO.getIsOpen());
        if (restaurantInfoBO.getExtra() != null) {
            restaurantDetailResponse.setImgList(restaurantInfoBO.getExtra().getImgList());
        }
        restaurantDetailResponse.setProvince(restaurantInfoBO.getProvince());
        restaurantDetailResponse.setCity(restaurantInfoBO.getCity());
        RestaurantDetailBO.POIInfo poiInfo = restaurantDetailBO.getPoiInfo();
        restaurantDetailResponse.setDistrict(poiInfo.getDistrict());
        restaurantDetailResponse.setTown(poiInfo.getTown());
        restaurantDetailResponse.setAddress(poiInfo.getAddress());
        restaurantDetailResponse.setPoiType(poiInfo.getPoiType());
        restaurantDetailResponse.setTypeList(poiInfo.getTypeList());
        restaurantDetailResponse.setLat(poiInfo.getLat());
        restaurantDetailResponse.setLon(poiInfo.getLon());
        restaurantDetailResponse.setIsShow(poiInfo.getIsShow());
        return restaurantDetailResponse;
    }

    public static List<RestaurantInfoResponse> convertToRestaurantInfoResponseList(List<RestaurantInfoBO> restaurantInfoBOS) {
        if (CollectionUtils.isEmpty(restaurantInfoBOS)) {
            return Lists.newArrayList();
        }
        return restaurantInfoBOS.stream().map(FoodConvert::convertToRestaurantInfoResponse).collect(Collectors.toList());
    }

    private static RestaurantInfoResponse convertToRestaurantInfoResponse(RestaurantInfoBO restaurantInfoBO) {
        if (restaurantInfoBO == null) {
            return null;
        }
        RestaurantInfoResponse restaurantInfoResponse = new RestaurantInfoResponse();
        restaurantInfoResponse.setRestaurantId(restaurantInfoBO.getRestaurantId());
        restaurantInfoResponse.setStorePoiId(restaurantInfoBO.getStorePoiId());
        restaurantInfoResponse.setName(restaurantInfoBO.getName());
        restaurantInfoResponse.setDesc(restaurantInfoBO.getDesc());
        restaurantInfoResponse.setRestaurantType(restaurantInfoBO.getRestaurantType());
        restaurantInfoResponse.setMoneyCost(restaurantInfoBO.getMoneyCost());
        restaurantInfoResponse.setScore(restaurantInfoBO.getScore());
        restaurantInfoResponse.setMainImg(restaurantInfoBO.getMainImg());
        restaurantInfoResponse.setBusinessTime(restaurantInfoBO.getBusinessTime());
        restaurantInfoResponse.setContactInfo(restaurantInfoBO.getContactInfo());
        restaurantInfoResponse.setIsOpen(restaurantInfoBO.getIsOpen());
        if (restaurantInfoBO.getExtra() != null) {
            restaurantInfoResponse.setImgList(restaurantInfoBO.getExtra().getImgList());
        }
        restaurantInfoResponse.setProvince(restaurantInfoBO.getProvince());
        restaurantInfoResponse.setCity(restaurantInfoBO.getCity());
        return restaurantInfoResponse;
    }

    public static List<FoodBaseVO> convertToFoodBaseVOList(List<FoodInfoBO> foodInfoBOList) {
        if (CollectionUtils.isEmpty(foodInfoBOList)) {
            return null;
        }
        List<FoodBaseVO> responseList = com.google.api.client.util.Lists.newArrayList();
        for (FoodInfoBO foodInfoBO : foodInfoBOList) {
            FoodBaseVO foodBaseVO = new FoodBaseVO();
            foodBaseVO.setFoodId(foodInfoBO.getFoodId());
            foodBaseVO.setName(foodInfoBO.getName());
            foodBaseVO.setRecommend(foodInfoBO.getRecommend());
            foodBaseVO.setRestaurantId(foodInfoBO.getRestaurantId());
            foodBaseVO.setFoodType(foodInfoBO.getFoodType() == null ? null : foodInfoBO.getFoodType().getType());
            foodBaseVO.setFoodTypeStr(foodInfoBO.getFoodType() == null ? null : foodInfoBO.getFoodType().getName());
            foodBaseVO.setPrice(foodInfoBO.getPrice());
            foodBaseVO.setMainImg(foodInfoBO.getMainImg());
            foodBaseVO.setSort(foodInfoBO.getSort());
            responseList.add(foodBaseVO);
        }
        return responseList;
    }

    public static FoodDetailVO convertToFoodDetailVO(FoodInfoBO foodInfoBO) {
        if (foodInfoBO == null) {
            return null;
        }
        FoodDetailVO response = new FoodDetailVO();
        response.setFoodId(foodInfoBO.getFoodId());
        response.setRestaurantId(foodInfoBO.getRestaurantId());
        response.setName(foodInfoBO.getName());
        response.setDesc(foodInfoBO.getDesc());
        response.setPrice(foodInfoBO.getPrice());
        response.setMainImg(foodInfoBO.getMainImg());
        response.setFoodType(foodInfoBO.getFoodType() == null ? null : foodInfoBO.getFoodType().getType());
        response.setRecommend(foodInfoBO.getRecommend());
        response.setSort(foodInfoBO.getSort());
        if (foodInfoBO.getBatching() != null) {
            FoodInfoBO.FoodBatching originBatching = foodInfoBO.getBatching();
            FoodDetailVO.FoodBatching batching = new FoodDetailVO.FoodBatching();
            batching.setBatching(originBatching.getBatching());
            batching.setMakeWay(originBatching.getMakeWay());
            response.setBatching(batching);
        }
        if (foodInfoBO.getExtra() != null) {
            FoodInfoBO.Extra originExtra = foodInfoBO.getExtra();
            FoodDetailVO.Extra extra = new FoodDetailVO.Extra();
            extra.setImgList(originExtra.getImgList());
            if (CollectionUtils.isNotEmpty(originExtra.getOutSideRelationList())) {
                List<FoodDetailVO.OutSideRelation> outSideRelationList = com.google.api.client.util.Lists.newArrayList();
                for (FoodInfoBO.OutSideRelation originOutSideRelation : originExtra.getOutSideRelationList()) {
                    FoodDetailVO.OutSideRelation outSideRelation = new FoodDetailVO.OutSideRelation();
                    outSideRelation.setRelationPlatform(originOutSideRelation.getRelationPlatform());
                    outSideRelation.setJumpUrl(originOutSideRelation.getJumpUrl());
                    outSideRelation.setExploreRecommend(originOutSideRelation.getExploreRecommend());
                    outSideRelationList.add(outSideRelation);
                }
                extra.setOutSideRelationList(outSideRelationList);
            }
            response.setExtra(extra);
        }
        return response;
    }

    public static RestaurantDetailVO convertToRestaurantDetailVO(RestaurantDetailBO restaurantDetailBO) {
        if (restaurantDetailBO == null || restaurantDetailBO.getRestaurantInfoBO() == null) {
            return null;
        }
        RestaurantInfoBO restaurantInfoBO = restaurantDetailBO.getRestaurantInfoBO();
        RestaurantDetailVO response = new RestaurantDetailVO();
        response.setContactInfo(restaurantInfoBO.getContactInfo());
        response.setCity(restaurantInfoBO.getCity());
        response.setDesc(restaurantInfoBO.getDesc());
        response.setMainImg(restaurantInfoBO.getMainImg());
        response.setMoneyCost(restaurantInfoBO.getMoneyCost());
        response.setName(restaurantInfoBO.getName());
        response.setProvince(restaurantInfoBO.getProvince());
        response.setScore(restaurantInfoBO.getScore());
        response.setRestaurantId(restaurantInfoBO.getRestaurantId());
        response.setStorePoiId(restaurantInfoBO.getStorePoiId());
        response.setBusinessTime(restaurantInfoBO.getBusinessTime());
        response.setRestaurantType(restaurantInfoBO.getRestaurantType());
        response.setIsOpen(restaurantInfoBO.getIsOpen());
        if (restaurantInfoBO.getExtra() != null) {
            response.setImgList(restaurantInfoBO.getExtra().getImgList());
        }

        if (restaurantDetailBO.getPoiInfo() != null) {
            RestaurantDetailBO.POIInfo poiInfo = restaurantDetailBO.getPoiInfo();
            response.setTypeList(poiInfo.getTypeList());
            response.setTown(poiInfo.getTown());
            response.setAddress(poiInfo.getAddress());
            response.setDistrict(poiInfo.getDistrict());
            response.setLon(poiInfo.getLon());
            response.setLat(poiInfo.getLat());
            response.setIsShow(poiInfo.getIsShow());
            response.setPoiType(poiInfo.getPoiType());
        }
        return response;
    }

    public static List<RestaurantBaseVO> convertToRestaurantBaseVOList(List<RestaurantInfoBO> restaurantInfoBOList) {
        if (CollectionUtils.isEmpty(restaurantInfoBOList)) {
            return com.google.api.client.util.Lists.newArrayList();
        }
        return restaurantInfoBOList.stream().map(FoodConvert::convertToRestaurantBaseVO).collect(Collectors.toList());
    }

    public static RestaurantBaseVO convertToRestaurantBaseVO(RestaurantInfoBO restaurantInfoBO) {
        if (restaurantInfoBO == null) {
            return null;
        }
        RestaurantBaseVO response = new RestaurantBaseVO();
        response.setMainImg(restaurantInfoBO.getMainImg());
        response.setMoneyCost(restaurantInfoBO.getMoneyCost());
        response.setName(restaurantInfoBO.getName());
        response.setScore(restaurantInfoBO.getScore());
        response.setRestaurantId(restaurantInfoBO.getRestaurantId());
        response.setRestaurantType(restaurantInfoBO.getRestaurantType());
        response.setIsOpen(restaurantInfoBO.getIsOpen());
        response.setProvince(restaurantInfoBO.getProvince());
        response.setCity(restaurantInfoBO.getCity());
        if (restaurantInfoBO.getExtra() != null) {
            response.setImgList(restaurantInfoBO.getExtra().getImgList());
        }
        response.setDesc(restaurantInfoBO.getDesc());
        response.setContactInfo(restaurantInfoBO.getContactInfo());
        response.setBusinessTime(restaurantInfoBO.getBusinessTime());
        return response;
    }

    public static PageResult<RestaurantBaseVO> convertToRestaurantBaseVOPage(PageResult<RestaurantInfoBO> pageResult) {
        if (pageResult == null) {
            return null;
        }
        if (CollectionUtils.isEmpty(pageResult.getResults())) {
            return PageResult.of(com.google.api.client.util.Lists.newArrayList(), pageResult.getPageNum(), pageResult.getPageSize(), pageResult.getTotal());
        }
        PageResult<RestaurantBaseVO> response = new PageResult<>();
        response.setCurrentIndex(pageResult.getCurrentIndex());
        response.setPageCount(pageResult.getPageCount());
        response.setResults(pageResult.getResults().stream().map(FoodConvert::convertToRestaurantBaseVO).collect(Collectors.toList()));
        response.setTotal(pageResult.getTotal());
        response.setHasNext(pageResult.isHasNext());
        return response;
    }
}
